﻿<script src="~/Scripts/jquery-easyui-extensions/combobox/jeasyui.extensions.combobox.getSelected.js"></script>

<div class="easyui-panel" data-options="fit:true,border:false" style="padding:20px;">
    <input id="combobox1" type="text" value="" />
    <br />
    这是个 单选 的 combobox。
    <br />
    <a id="btnGet" class="easyui-linkbutton" data-options="iconCls:'icon-add'">获取已选项，并输出其序列化结果</a>
</div>
<script>
    $(function () {

        var data = [
            { value: "1", text: "蜘蛛侠" },
            { value: "2", text: "蝙蝠侠" },
            { value: "3", text: "钢铁侠" },
            { value: "4", text: "神奇四侠" },
            { value: "5", text: "接盘侠" }
        ];
        $("#combobox1").combobox({
            valueField: "value",
            textField: "text",
            data: data,
            multiple: false,
            editable: false
        });

        $("#btnGet").click(function () {
            var selected = $("#combobox1").combobox("getSelected");
            if (selected)
            {
                alert(JSON.stringify(selected));
            }
            else
            { alert("尚未选择！请选择一项。"); }
        });

    });
</script>
